home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / win_q_t / trem.zip / CREATE.C < prev    next >
Text File  |  1991-05-11  |  4KB  |  124 lines

  1. /************************************************************************
  2.  *
  3.  *    Copyright (c) 1991 Microsoft Corporation.  All Rights Reserved.
  4.  *
  5.  *-----------------------------------------------------------------------
  6.  *
  7.  *     Project:  Windows Terminal Example
  8.  *
  9.  *      Module:  create.c
  10.  *
  11.  *      Author:  Bryan A. Woodruff (baw)
  12.  *
  13.  *
  14.  *     Remarks:  Routines to create terminal information
  15.  *
  16.  *   Revisions:
  17.  *     01.00.000  5/ 9/91 baw   Wrote it
  18.  *
  19.  ************************************************************************/
  20.  
  21. #include "terminal.h"
  22.  
  23. /************************************************************************
  24.  *  LOCALHANDLE CreateTerminal( HWND hWnd )
  25.  *
  26.  *  Description:
  27.  *     Creates block, and initializes it.
  28.  *
  29.  *  Comments:
  30.  *      5/ 9/91  baw  Wrote it
  31.  *
  32.  ************************************************************************/
  33.  
  34. LOCALHANDLE CreateTerminal( HWND hWnd )
  35. {
  36.    HDC          hDC ;
  37.    LOCALHANDLE  hTermInfo ;
  38.    NPTERMINFO   npTermInfo ;
  39.    TEXTMETRIC   tm ;
  40.  
  41.    if (NULL == (hTermInfo = LocalAlloc( LMEM_MOVEABLE, sizeof( TERMINFO ) )))
  42.       return ( NULL ) ;
  43.  
  44.    if (NULL == (npTermInfo = (NPTERMINFO) LocalLock( hTermInfo )))
  45.    {
  46.       LocalFree( hTermInfo ) ;
  47.       return ( NULL ) ;
  48.    }
  49.  
  50.    npTermInfo -> nCid = 0 ;
  51.    npTermInfo -> fConnected = FALSE ;
  52.    npTermInfo -> fLocalEcho = FALSE ;
  53.    npTermInfo -> fAutoWrap = TRUE ;
  54.    npTermInfo -> bPort = 1 ;
  55.    npTermInfo -> wBaudRate = 9600 ;
  56.    npTermInfo -> bByteSize = 8 ;
  57.    npTermInfo -> bFlowCtrl = FC_HARDWARE ;
  58.    npTermInfo -> bParity = NOPARITY ;
  59.    npTermInfo -> bStopBits = ONESTOPBIT ;
  60.    npTermInfo -> fXonXoff = FALSE ;
  61.    npTermInfo -> xSize = 0 ;
  62.    npTermInfo -> ySize = 0 ;
  63.    npTermInfo -> xScroll = 0 ;
  64.    npTermInfo -> yScroll = 0 ;
  65.    npTermInfo -> xOffset = 0 ;
  66.    npTermInfo -> yOffset = 0 ;
  67.    npTermInfo -> nColumn = 0 ;
  68.    npTermInfo -> nRow = 0 ;
  69.    _fmemset( npTermInfo -> abScreen, ' ', MAXROWS * MAXCOLS ) ;
  70.  
  71.    npTermInfo -> hFont = CreateTerminalFont() ;
  72.  
  73.    hDC = GetDC( hWnd ) ;
  74.    npTermInfo -> hDefaultFont = SelectObject( hDC, npTermInfo -> hFont ) ;
  75.    GetTextMetrics( hDC, &tm ) ;
  76.    ReleaseDC( hWnd, hDC ) ;
  77.  
  78.    npTermInfo -> xChar = tm.tmAveCharWidth  ;
  79.    npTermInfo -> yChar = tm.tmHeight + tm.tmExternalLeading ;
  80.  
  81.    LocalUnlock( hTermInfo ) ;
  82.  
  83.    return ( hTermInfo ) ;
  84.  
  85. } /* end of CreateTerminal() */
  86.  
  87. /************************************************************************
  88.  *  HFONT CreateTerminalFont( VOID )
  89.  *
  90.  *  Description: 
  91.  *
  92.  *
  93.  *  Comments:
  94.  *
  95.  ************************************************************************/
  96.  
  97. HFONT CreateTerminalFont( VOID )
  98. {
  99.    LOGFONT  lf ;
  100.  
  101.    lf.lfHeight =         12 ;
  102.    lf.lfWidth =          8 ;
  103.    lf.lfEscapement =     0 ;
  104.    lf.lfOrientation =    0 ;
  105.    lf.lfWeight =         0 ;
  106.    lf.lfItalic =         0 ;
  107.    lf.lfUnderline =      0 ;
  108.    lf.lfStrikeOut =      0 ;
  109.    lf.lfCharSet =        OEM_CHARSET ;
  110.    lf.lfOutPrecision =   OUT_DEFAULT_PRECIS ;
  111.    lf.lfClipPrecision =  CLIP_DEFAULT_PRECIS ;
  112.    lf.lfQuality =        DEFAULT_QUALITY ;
  113.    lf.lfPitchAndFamily = FIXED_PITCH | FF_MODERN ;
  114.    lf.lfFaceName[0] =    NULL ;
  115.  
  116.    return(  CreateFontIndirect( &lf ) ) ;
  117.  
  118. } /* end of CreateTerminalFont() */
  119.  
  120. /************************************************************************
  121.  * End of File: create.c
  122.  ************************************************************************/
  123.  
  124.